package com.zzptc;

public class Storage {
	private int r;
	private boolean isEmpty=true;
	
	synchronized void put(int i){
		while(! isEmpty){
			try{
				this.wait();
			}catch(InterruptedException e){
				System.out.println(e. getMessage());}
			}
			r=i;
			isEmpty=false;
			notify();
		}
		synchronized int get(){
			while(isEmpty){
				try{
					this.wait();
				}catch(InterruptedException e){
					System.out.println(e. getMessage());}
				}
			isEmpty=true;
			notify();
			return r ;	
	}
}
